Compute azimuth angle of the Sun's position in the north-clockwise convention
References:
Oke, T.R., Boundary layer climates, Second edition, Routledge, 1987. Appendix A1, eq. A1.2
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(DateTime), | intent(in) | :: | time | |||
real(kind=float), | intent(in) | :: | lat |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=float), | public | :: | a1 | ||||
real(kind=float), | public | :: | d | ||||
integer(kind=short), | public | :: | t | ||||
real(kind=float), | public | :: | term | ||||
real(kind=float), | public | :: | w |
FUNCTION SolarAzimuth & ! (time, lat) & ! RESULT (az) IMPLICIT NONE !Arguments with intent(in): TYPE (DateTime), INTENT(in) :: time REAL (KIND = float), INTENT(in) :: lat !latitude [radians] !local declarations: REAL (KIND = float) :: az !solar azimuth [radians] REAL (KIND = float) :: w ! hour angle [radians] REAL (KIND = float) :: d ! solar declination [radians] REAL (KIND = float) :: a1 ! sun elevation angle [radians] INTEGER (KIND = short) :: t !hour REAL (KIND = float) :: term !------------------------------------end of declarations----------------------- !compute hour angle w = SolarHourAngle (time) !compute declination d = SolarDeclination (time) !compute sun elevation angle a1 = SunElevationAngle (time, lat) !get hour t = GetHour (time) term = ( SIN (d) * COS (lat) - COS (d) * SIN (lat) * COS (w) ) / COS (a1) ! compute azimuth IF ( term < -1.) THEN az = pi ELSE IF (term > 1.) THEN az = 0. ELSE IF (t <= 12) THEN az = ACOS ( term ) ELSE az = 2. * pi - ACOS ( term ) END IF RETURN END FUNCTION SolarAzimuth